package org.dashboard.client.widget.alarm;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author Simon Vogensen, Lakeside
 * @version $Revision$
 */
public class AlarmWidget extends SimplePanel implements Alarm {
    interface Binder extends UiBinder<Widget, AlarmWidget> {
    }

    private static final Binder binder = GWT.create(Binder.class);

    public AlarmWidget() {
        super();

        setWidget(binder.createAndBindUi(this));
    }

    public void start() {
        this.setVisible(true);
        startAlarmSound();
    }

    public void stop() {
        this.setVisible(false);
        stopAlarmSound();
    }

    public static native void startAlarmSound() /*-{
        $doc.getElementById("alarmSound").play()
//        $wnd.alert($doc.getElementById("alarmSound"))
    }-*/;

    public static native void stopAlarmSound() /*-{
        $doc.getElementById("alarmSound").pause()
    }-*/;

}
